Page({
  data: {
    bo:true,
    sliderV:0,
    sliderMax: 414,
    current: {
      poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
      name: '此时此刻',
      author: '许巍',
      src: 'https://img.kuang100.net/daoyou/yinping/1568713339138.mp3',
    },
    audioAction: {
      method: 'pause'
    }
  },
  audioPlayed: function (e) {
    console.log('audio is played')
  },

  audioTimeUpdated: function (e) {

    if (this.data.bo) {
    console.log("正在播放")
    //设置滚动条
    this.setData({
      sliderV: e.detail.currentTime,
      bo: true
    });
    this.duration = e.detail.duration;
    }
  },

  timeSliderChanged: function (e) {
    console.log("拖动完成")
    
    if (!this.data.bo){
      this.setData({
        bo:true,
        audioAction: {
          method: 'setCurrentTime',
          data: e.detail.value
        }
      });
    }
  
  },


  
  Changed: function(e) {
    console.log("正在拖动")
    this.setData({
      bo: false
    });
  },




  playAudio: function () {
    this.setData({
      audioAction: {
        method: 'play'
      }
    });
  },
  pauseAudio: function () {
    this.setData({
      audioAction: {
        method: 'pause'
      }
    });
  },

  /**
   * 将秒转换为 分:秒
   * s int 秒数
  */
  formatMinute(s) {
    //计算分钟
    //算法：将秒数除以60，然后下舍入，既得到分钟数
    var h;
    h = Math.floor(s / 60);
    //计算秒
    //算法：取得秒%60的余数，既得到秒数
    s = s % 60;
    //将变量转换为字符串
    h += '';
    s += '';
    //如果只有一位数，前面增加一个0
    h = (h.length == 1) ? '0' + h : h;
    s = (s.length == 1) ? '0' + s : s;
    return h + ':' + s ;
  }





})